<template>
  <div style="margin:5px 0 5px 0">
    {{"当前答题剩余有效时间"+times+"秒"}}
    <el-button type="primary" @click="getTime">开始答题</el-button>
  </div>

</template>

<script>
export default {
  name:'timeChange',
  data() {
    return {
      times: 250,   //倒计时250s，可以任意设定数字
    }
  },
  created() {
    //this.getTime();   //只要该页面一渲染创建，就开始倒计时
  },
  methods:{
    getTime() {
      this.timer = setInterval(()=>{
        this.times--
        if(this.times===0){
          clearInterval(this.timer)
        }
      },1000)
    }
  }
}
</script>

<style scoped>
.cardBox {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 92%;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  text-align: center;
  padding: 15px;
  padding-top: 15px;
}
.erweiPhoto{
  width: 220px;
}
</style>
